package controller

import (
	"audio/model"
	"audio/utils"
	"github.com/gin-gonic/gin"
	"strconv"
	"time"
)

/**
 * 获取js配置信息
 */
func JsConfigInfo() gin.HandlerFunc {
	return func(c *gin.Context) {
		noncestr := c.DefaultQuery("noncestr", "")
		url := c.DefaultQuery("url", "")
		timestamp := strconv.FormatInt(time.Now().Unix(), 10)
		ticket := utils.GetJsTicket()
		signature := utils.GetJsSignature(noncestr, ticket, timestamp,url)

		c.JSON(200, gin.H{
			"appId":     model.WechatConfig.AppId,
			"timestamp": timestamp,
			"sign":      signature,
			"ticket":    ticket,
		})
	}
}
